using UnityEngine.UI;

namespace UnityEngine.EventSystems
{
    /// <summary>
    /// Interface to the Input system used by the BaseInputModule. With this it is possible to bypass the Input system with your own but still use the same InputModule. For example this can be used to feed fake input into the UI or interface with a different input system.
    /// </summary>
    public class BaseInput : UIBehaviour
    {
        /// <summary>
        /// Interface to Input.compositionString. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual string compositionString
        {
            get
            {
#if NEW_INPUT_SYSTEM_ONLY
                return "";
#else
                return Input.compositionString;
#endif
            }
        }

        /// <summary>
        /// Interface to Input.imeCompositionMode. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual IMECompositionMode imeCompositionMode
        {
            get
            {
#if NEW_INPUT_SYSTEM_ONLY
                return IMECompositionMode.Auto;
#else
                return Input.imeCompositionMode; 
#endif
            }
            set
            {
#if NEW_INPUT_SYSTEM_ONLY
#else
                Input.imeCompositionMode = value; 
#endif
            }
        }

        /// <summary>
        /// Interface to Input.compositionCursorPos. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual Vector2 compositionCursorPos
        {
            get
            {

#if NEW_INPUT_SYSTEM_ONLY
                return Vector2.zero;
#else
                return Input.compositionCursorPos;
#endif
            }
            set
            {
#if NEW_INPUT_SYSTEM_ONLY
#else
                Input.compositionCursorPos = value;
#endif
            }
        }

        /// <summary>
        /// Interface to Input.mousePresent. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual bool mousePresent
        {
            get
            {
#if NEW_INPUT_SYSTEM_ONLY
                return false;
#else
                return Input.mousePresent; 
#endif
            }
        }

        /// <summary>
        /// Interface to Input.GetMouseButtonDown. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        /// <param name="button"></param>
        /// <returns></returns>
        public virtual bool GetMouseButtonDown(int button)
        {
#if NEW_INPUT_SYSTEM_ONLY
            return false;
#else
            return Input.GetMouseButtonDown(button);
#endif
        }

        /// <summary>
        /// Interface to Input.GetMouseButtonUp. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual bool GetMouseButtonUp(int button)
        {
#if NEW_INPUT_SYSTEM_ONLY
            return false;
#else
            return Input.GetMouseButtonUp(button);
#endif
        }

        /// <summary>
        /// Interface to Input.GetMouseButton. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual bool GetMouseButton(int button)
        {
#if NEW_INPUT_SYSTEM_ONLY
            return false;
#else
            return Input.GetMouseButton(button);
#endif
        }

        /// <summary>
        /// Interface to Input.mousePosition. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual Vector2 mousePosition
        {
            get
            {

#if NEW_INPUT_SYSTEM_ONLY
                return Vector2.zero;
#else
                return Input.mousePosition; 
#endif
            }
        }

        /// <summary>
        /// Interface to Input.mouseScrollDelta. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual Vector2 mouseScrollDelta
        {
            get
            {

#if NEW_INPUT_SYSTEM_ONLY
                return Vector2.zero;
#else
                return Input.mouseScrollDelta;
#endif
            }
        }

        /// <summary>
        /// Interface to Input.touchSupported. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual bool touchSupported
        {
            get
            {

#if NEW_INPUT_SYSTEM_ONLY
                return false;
#else
                return Input.touchSupported;
#endif
            }
        }

        /// <summary>
        /// Interface to Input.touchCount. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        public virtual int touchCount
        {
            get
            {

#if NEW_INPUT_SYSTEM_ONLY
                return 0;
#else
                return Input.touchCount;
#endif
            }
        }

        /// <summary>
        /// Interface to Input.GetTouch. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        /// <param name="index">Touch index to get</param>
        public virtual Touch GetTouch(int index)
        {
#if NEW_INPUT_SYSTEM_ONLY
            return default;
#else
            return Input.GetTouch(index);
#endif
        }

        /// <summary>
        /// Interface to Input.GetAxisRaw. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        /// <param name="axisName">Axis name to check</param>
        public virtual float GetAxisRaw(string axisName)
        {
#if NEW_INPUT_SYSTEM_ONLY
            return 0;
#else
            return Input.GetAxisRaw(axisName);
#endif
        }

        /// <summary>
        /// Interface to Input.GetButtonDown. Can be overridden to provide custom input instead of using the Input class.
        /// </summary>
        /// <param name="buttonName">Button name to get</param>
        public virtual bool GetButtonDown(string buttonName)
        {
#if NEW_INPUT_SYSTEM_ONLY
            return false;
#else
            return Input.GetButtonDown(buttonName);
#endif
        }
    }
}
